<?php

namespace app\admin\model;


class Intentionorder extends Base
{
    // 表名
    protected $name = 'pur_intentionorder';

    //产品
    public function material()
    {
        return $this->belongsTo("Material", 'fk_bdl_bd_material');
    }
    public function mater()
    {
        return $this->hasone("Material", 'fk_bdl_bd_material');
    }

    //表面
    public function surface()
    {
        return $this->hasone("Surface",'fnumber', 'fk_bdl_bd_surface');
    }
    //材质
    public function texture()
    {
        return $this->hasone("Texture",'fnumber', 'fk_bdl_bd_texture');
    }

    //状态
    public function getStatusList()
    {
        return ["1" => "待确认", "2" => "已确认"];
    }

    //类型
    public function getTypeList()
    {
        return ["1" => "期货", "2" => "现货"];
    }

    //客户
    public function customer()
    {
        return $this->hasOne('Customer','id','fk_bdl_bd_customer',[],'LEFT')->setEagerlyType(0);
    }
    //用户
    public function wxuser()
    {
        return $this->hasOne('Wxuser','id','fk_bdl_userid');
    }

    //地址
    public function address()
    {
        return $this->hasOne("Customeraddress",'id','fk_bdl_bd_useraddress',[],'LEFT')->setEagerlyType(0);
    }

    //订单关联
    public function orderentry()
    {
        return $this->hasMany("Intentionorderentry", 'id','id')->with(['material','inventory']);
    }

    //订单关联
    public function orderentrynew()
    {
        return $this->hasMany("Intentionorderentry", 'id','id')->with(['inventoryone','material']);
    }
    public function orderent()
    {
        return $this->hasMany("Intentionorderentry", 'id','id');
    }
    public function cate()
    {
        return $this->hasOne("Materialcate",'id','fk_bdl_bd_material_g');
    }


}
